package com.lc.afbx.adapters;

import android.content.Context;
import android.net.Uri;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.conn.GetApiJiaMengJiGou;
import com.zcx.helper.util.UtilLog;

import java.util.List;

/**
 * Created by Administrator on 2016/5/28.
 */
public class AdapterJiaMengJiGou extends BaseAdapter {

    private Context context;
    private List<GetApiJiaMengJiGou.Data> dataList;
    private LayoutInflater inflater;

    public AdapterJiaMengJiGou(Context context, List<GetApiJiaMengJiGou.Data> dataList) {
        this.context = context;
        this.dataList = dataList;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return dataList.size();
    }

    @Override
    public Object getItem(int position) {
        return dataList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;
        if (convertView == null) {

            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_jiamengjigou_gridview, null);
            BaseApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);
            convertView.setBackgroundColor(context.getResources().getColor(R.color.white));

            holder.img = (SimpleDraweeView) convertView.findViewById(R.id.img_jiamengjigou_gird);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }


        holder.img.setImageURI(Uri.parse(dataList.get(position).picurl));
        UtilLog.e("---------------->", dataList.get(position).picurl);
//        BaseApplication.UtilAsyncListBitmap.get(dataList.get(position).picurl, holder.img, R.mipmap.jiamengjigou);

        return convertView;
    }

    class ViewHolder {

        SimpleDraweeView img;
    }
}
